<template>
    <page-container>

        <cu-custom slot="header" :isBack="true" bgColor="bg-white">
            <block slot="content">评价</block>
        </cu-custom>

        <!-- 数据列表 -->
        <view class="order-row" slot="center">
            <view class="order-row-item">
                <block v-for="(item,index) in goodsobj.order_goods" :key="index">
                    <view class="order-row-top df-cen-rl">
                        <view class="df-ai-cen">
                            <text class="cuIcon-shop" style="font-size: 28rpx;"></text>
                            <view class="site-name" @click="toshop(item)">{{item.site_name}}</view>
                            <text class="cuIcon-right" style="font-size: 28rpx;"></text>
                        </view>
                    </view>
                    <view class="df margin-top">
                        <image :src="item.sku_image" mode="" class="item-img"></image>
                        <view class="df order-info-right">
                            <view class="order-info-title">{{item.sku_name}}</view>
                            <view class="info-price">
                                <view>￥{{Number(item.price*item.num).toFixed(2)}}</view>
                                <view>X {{item.num}}</view>
                            </view>
                        </view>
                    </view>
                </block>
                <view class="dppj">
                    <view class="dppj-text">店铺评价</view>
                    <view class="stars-wrapper">
                        <!-- @mouseenter="enter(n)" @mouseleave="leave()" 真机不存在这两个事件 -->
                        <!-- 遍历需要添加key作为更新虚拟dom属性-diff  vue语法中必传的唯一标识 -->
                        <view v-for="n in 5" @click="Selected(n)" :class="{'on':cur < n}" :key="n">
                        </view>
                    </view>
                </view>
                <view class="top-text">
                    <textarea v-model="txt" placeholder-style="color:#999999" placeholder="满意你就夸一夸" confirm-type="done" />
                </view>
                <view class="isgoux">
                    <view class="gouicon" v-if="shows==true" @click="showshad()">
                        <image src="https://toc.nanyuecloud.com/toc-inst-app/zqanswer/test/img/xmg/gouxuan.png" mode=""></image>
                    </view>
                    <view class="gouiconnot" v-if="shows==false" @click="showshad()"></view>
                    <view class="gkk">公开</view>
                </view>
            </view>
            <view class="btnFrom" @click="release(goodsobj)">
                发布
            </view>
        </view>
    </page-container>
</template>
<script>
export default {
	data() {
		return {
			cur: 4,
			flag: false, // 鼠标点击后变成true，鼠标进入进出事件就不会改变背景图
			shows: false,
			order_id: '',
			goodsobj: {},
			txt: ''
		}
	},
	components: {},
	computed: {},
	mounted() {

	},
	onShow() {
		this.order_id = this.$Router.queryObj().order_id
		this.getGoodssku(this.order_id)
	},
	methods: {
		enter(idx) {
			if (!this.flag) {
				this.cur = idx
			}
			if (this.cur < 1) {
				this.cur = 1
			}
		},
		leave() {
			if (!this.flag) {
				this.cur = -1
			}
			if (this.cur < 1) {
				this.cur = 1
			}
		},
		Selected(n) {
			if (this.cur < 1) {
				this.cur = 1
			}
			this.cur = n
		},
		getGoodssku(order_id) {
			this.$request.orderDetail({
				order_id
			}).then(res => {
				console.log(res)
				this.goodsobj = res.data
			})
		},
		showshad() {
			this.shows = !this.shows
			console.log(this.shows)
		},
		toshop(item) {
			this.$util.redirectTo('/shopPages/shop/shop', {
				site_id: item.site_id
			})

		},
		release(goodsobj) {
			if (this.txt == '') {
				this.$Utils.tip('满意你就夸一夸吧~')
				return
			}
			let showtext = 0
			if (this.shows == false) {
				showtext = 1
			} else {
				showtext = 0
			}
			let arr = []
			goodsobj.order_goods.map((item, index) => {
				arr.push({
					order_goods_id: item.order_goods_id,
					goods_id: item.goods_id,
					sku_id: item.sku_id,
					site_id: item.site_id,
					sku_name: item.sku_name,
					sku_price: item.price,
					sku_image: item.sku_image,
					content: this.txt,
					images: '',
					scores: this.cur,
					explain_type: 1
				})
			})
			console.log('arr', JSON.stringify(arr))
			this.$request.goodsevaluateAdd({
				order_id: this.order_id,
				is_anonymous: showtext,
				goods_evaluate: JSON.stringify(arr),
				shop_desccredit: this.cur
			}).then(res => {
				// console.log("---提交评价返回---",res)
				this.$util.tip('感谢你的评价~')
				setTimeout(() => {
					uni.navigateBack({
						delta: 2
					})
				}, 1000)
			})
		}
	}
}
</script>
<style lang="scss" scoped>
image {
    width: 100%;
    height: 100%;
}
.order-row {
    padding: 20rpx 20rpx 0 20rpx;

    .order-row-item {
        width: 100%;
        padding: 20rpx 30rpx;
        margin-bottom: 20rpx;
        background-color: #ffffff;
        border-radius: 20rpx;

        .item-img {
            width: 140rpx;
            height: 140rpx;
            border-radius: 20rpx;
        }

        .item-info-title {
            margin-bottom: 20rpx;
        }

        .site-name {
            margin: 0 20rpx;
            font-size: 28rpx;
            font-family: PingFang SC;
            font-weight: 500;
            color: #222222;
        }
    }

    .order-info-right {
        margin-left: 30rpx;
        flex: 1;
        justify-content: space-around;

        .order-info-title {
            width: 330rpx;
            font-size: 24rpx;
            font-family: PingFang SC;
            font-weight: 500;
            color: #000000;
        }

        .info-price {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }
    }

    .order-type {
        padding-top: 10rpx;
    }
}

.ativer-bottom {
    /* #ifdef MP-WEIXIN */
    padding-bottom: 100rpx;
    /* #endif */
    /* #ifdef H5 */
    // padding-bottom: 40rpx;
    /* #endif */
}

.seelogs {
    width: 160rpx;
    height: 56rpx;
    background: rgba(255, 68, 46, 0);
    border: 1rpx solid #cccccc;
    border-radius: 28rpx;
    font-size: 24rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #666666;
    text-align: center;
    line-height: 56rpx;
}

.dppj {
    display: flex;
    align-items: center;
    padding-top: 35rpx;
    padding-bottom: 43rpx;
}

.dppj-text {
    font-size: 28rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #212121;
    padding-right: 66rpx;
}

.stars-wrapper {
    display: flex;
}

.stars-wrapper view {
    width: 40rpx;
    height: 40rpx;
    background-image: url("https://toc.nanyuecloud.com/toc-inst-app/zqanswer/test/img/xmg/starticon.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    margin-left: 10rpx;
    margin-right: 10rpx;
}

.stars-wrapper .on {
    background-image: url("https://toc.nanyuecloud.com/toc-inst-app/zqanswer/test/img/xmg/notstart.png");
}
.top-text {
    width: 660rpx;
    height: 220rpx;
    background: #f4f4f4;
    border-radius: 16rpx;
}

.isgoux {
    display: flex;
    align-items: center;
    padding-top: 30rpx;
    .gouicon {
        width: 40rpx;
        height: 40rpx;
        margin-right: 21rpx;
    }
    .gouiconnot {
        width: 40rpx;
        height: 40rpx;
        margin-right: 21rpx;
        background: #f4f4f4;
        border-radius: 50%;
    }
    .gkk {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #212121;
    }
}
/deep/uni-textarea {
    width: 300px;
    height: 110px;
    display: block;
    position: relative;
    font-size: 28rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #cccccc;
    line-height: normal;
    white-space: pre-wrap;
    word-break: break-all;
    padding: 26rpx;
}
.btnFrom {
    width: 702rpx;
    height: 80rpx;
    background: linear-gradient(90deg, #ff6744, #fd3b5c);
    border-radius: 40rpx;
    margin: 30rpx auto 0 auto;
    font-size: 32rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #ffffff;
    line-height: 80rpx;
    text-align: center;
}
</style>
